﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Ovvio.Web.Core;
using Ovvio.Business;
using Ovvio.Web.Areas.Admin.Models;
using Ovvio.Data;

namespace Ovvio.Web.Areas.Admin.ModelProviders
{
    public class UserModelProvider : ModelProvider<int, UserModel, User, OvvioDataContext>
    {
        public UserModelProvider() : base(p => p.Id, new UserService()) { }

        public override bool Save(UserModel model)
        {
            if (!string.IsNullOrEmpty(model.Password))
                model.Entity.SetPassword(model.Password);

            return base.Save(model);
        }
    }
}
